<html>
<head><meta charset="utf-8"><title>How can I dump llvm ir for each llvm pass · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/How.20can.20I.20dump.20llvm.20ir.20for.20each.20llvm.20pass.html">How can I dump llvm ir for each llvm pass</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="214921477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/How%20can%20I%20dump%20llvm%20ir%20for%20each%20llvm%20pass/near/214921477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mike Hommey <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/How.20can.20I.20dump.20llvm.20ir.20for.20each.20llvm.20pass.html#214921477">(Oct 29 2020 at 02:58)</a>:</h4>
<p>Does the rust compiler have something special to do that or do I need to fiddle with llvm flags?</p>



<a name="214921628"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/How%20can%20I%20dump%20llvm%20ir%20for%20each%20llvm%20pass/near/214921628" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/How.20can.20I.20dump.20llvm.20ir.20for.20each.20llvm.20pass.html#214921628">(Oct 29 2020 at 03:00)</a>:</h4>
<p>for <em>each</em> pass? I don't know if there's a way. If you just way the final IR you can use <code>--emit llvm-ir</code> though</p>



<a name="214921788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/How%20can%20I%20dump%20llvm%20ir%20for%20each%20llvm%20pass/near/214921788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mike Hommey <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/How.20can.20I.20dump.20llvm.20ir.20for.20each.20llvm.20pass.html#214921788">(Oct 29 2020 at 03:03)</a>:</h4>
<p>save-temps also adds no-opt, which I suppose is the IR as rustc sends it to llvm. I guess I just have to play with llvm flags.</p>



<a name="214921958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/How%20can%20I%20dump%20llvm%20ir%20for%20each%20llvm%20pass/near/214921958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tyson Nottingham <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/How.20can.20I.20dump.20llvm.20ir.20for.20each.20llvm.20pass.html#214921958">(Oct 29 2020 at 03:07)</a>:</h4>
<p>You can pass something like this to rustc:</p>
<p><code>-C llvm-args='-print-after-all -filter-print-funcs=your_mangled_function_name' -C codegen-units=1</code></p>
<p>More details here -- <a href="https://rustc-dev-guide.rust-lang.org/backend/debugging.html?highlight=print-after-all#debugging-llvm">https://rustc-dev-guide.rust-lang.org/backend/debugging.html?highlight=print-after-all#debugging-llvm</a></p>



<a name="214928050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/How%20can%20I%20dump%20llvm%20ir%20for%20each%20llvm%20pass/near/214928050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mike Hommey <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/How.20can.20I.20dump.20llvm.20ir.20for.20each.20llvm.20pass.html#214928050">(Oct 29 2020 at 05:27)</a>:</h4>
<p><span class="user-mention" data-user-id="306073">@Tyson Nottingham</span> thank you</p>



<a name="214929551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/How%20can%20I%20dump%20llvm%20ir%20for%20each%20llvm%20pass/near/214929551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mike Hommey <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/How.20can.20I.20dump.20llvm.20ir.20for.20each.20llvm.20pass.html#214929551">(Oct 29 2020 at 06:05)</a>:</h4>
<p>(BTW, interestingly, the thing I'm trying to track down only happens with -C codegen-units=1)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>